﻿public class Solution {
    public int MaxProfit(int[] prices)
    {
        int result = 0;
        int temp;
        for (int i = 1; i < prices.Length; i++)
        {
            temp = prices[i] - prices[i - 1];
            if (temp > 0) result += temp;
        }

        return result;
    }

    public static void Main(string[] args)
    {
        int[] prices = [7, 1, 5, 3, 6, 4];
        Solution solution = new Solution();
        int result = solution.MaxProfit(prices);
        Console.WriteLine(result);
    }
}